/* 
 * File:   UartHelper.h
 * Author: root
 *
 * Created on May 8, 2020, 4:38 PM
 */

#ifndef UARTHELPER_H
#define	UARTHELPER_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <termios.h>

class UartHelper {
public:
    
    UartHelper();
    UartHelper(const UartHelper& orig);
    virtual ~UartHelper();
    
    char initSerialDev(int fd, int speed, int databits, int stopbits, int parity);
    int getFd(void){ return fd; };
    int uartOpen(char *deviceName);
    
    int uartRead(char *buf, int len);
    //int write(char *bug, int len);

private:

    int fd;
    
    void set_speed(int fd, int speed);
    int set_Parity(int fd,int databits,int stopbits,int parity);
    
};

#endif	/* UARTHELPER_H */

